package com.movie.entity;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.PositiveOrZero;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * VIP等级实体
 * 定义用户的VIP等级和权益
 */
@Data
@Entity
@Table(name = "vip_levels")
public class VipLevel {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    @NotBlank(message = "等级名称不能为空")
    @Column(nullable = false, unique = true)
    private String name;
    
    @NotBlank(message = "等级描述不能为空")
    @Column(length = 500)
    private String description;
    
    @NotNull(message = "等级不能为空")
    @Column(nullable = false, unique = true)
    private Integer level;
    
    @Column(name = "monthly_price", precision = 10, scale = 2)
    private BigDecimal monthlyPrice;
    
    @Column(name = "yearly_price", precision = 10, scale = 2)
    private BigDecimal yearlyPrice;
    
    @Column(name = "discount_rate")
    private Integer discountRate; // 折扣率，如10表示9折
    
    @Column(name = "max_watch_time")
    private Integer maxWatchTime; // 最大观看时长（小时）
    
    @Column(name = "max_download_count")
    private Integer maxDownloadCount; // 最大下载次数
    
    @Column(name = "ad_free", nullable = false)
    private Boolean adFree = false;
    
    @Column(name = "hd_quality", nullable = false)
    private Boolean hdQuality = false;
    
    @Column(name = "priority_support", nullable = false)
    private Boolean prioritySupport = false;
    
    @Column(name = "exclusive_content", nullable = false)
    private Boolean exclusiveContent = false;
    
    @Column(name = "color")
    private String color; // 等级颜色，用于UI显示
    
    @Column(name = "icon_url")
    private String iconUrl; // 等级图标URL
    
    @PositiveOrZero
    @Column(name = "required_points", nullable = false)
    private Integer requiredPoints = 0; // 升级所需积分
    
    @Column(nullable = false)
    private Boolean status = true;
    
    @Column(name = "sort_order", nullable = false)
    private Integer sortOrder = 0;
    
    @CreationTimestamp
    @Column(name = "created_at", updatable = false)
    private LocalDateTime createdAt;
    
    @UpdateTimestamp
    @Column(name = "updated_at")
    private LocalDateTime updatedAt;
}